Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-125880: Fix exit codes in PyREPL #125890

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Eclips4
Copy link
Member

@Eclips4 Eclips4 commented Oct 23, 2024

@Eclips4 Eclips4 marked this pull request as ready for review October 26, 2024 22:01
@@ -101,6 +101,7 @@ pymain_err_print(int *exitcode_p)
int exitcode;
if (_Py_HandleSystemExit(&exitcode)) {
*exitcode_p = exitcode;
Py_Exit(exitcode);
Copy link
Member Author

@Eclips4 Eclips4 Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed in order to match behavior of PyRUn_AnyFileExFlags(which the old REPL called an still calls if PYTHON_BASIC_REPL=1) which somewhere calls handle_system_exit (Python/pythonrun.c::L632)) which handles SystemExit and calls Py_Exit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case this path doesn't return as this calls PyFinalize_Ex and then exit()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as previous approach with PyRun_AnyFileExFlags, so, is this a problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow what you mean. Could you clarify ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not being clear!
I mean, the previous approach with PyRun_AnyFileExFlags contains path with handle_system_exit which is also didn't return as it calls PyFinalizeEx and then exit().

@Eclips4 Eclips4 added the needs backport to 3.13 bugs and security fixes label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants